#商品列表页
from pages.base_page import BasePage
from pages.elements import Elements
from pages.product_detail_page import ProductDetailPage
from utils.log_manager import my_logger
class ProductListPage(BasePage):

    product_names_ele = {'type': 'xpath', 'value': '//div[@class="product-thumb"]//h4/a'}
    first_product_ele = {'type': 'xpath', 'value': '(//div[@class="product-thumb"]//h4/a)[1]'}

    def get_all_product_names(self):
        return self.get_texts(self.product_names_ele['value'], by=self.product_names_ele['type'])

    def select_first_product(self):
        self.click_element(self.first_product_ele['value'], by=self.first_product_ele['type'])
        return ProductDetailPage()

    def click_first_product(self):
        my_logger.logger.debug("点击第一个元素:{}",self.driver.current_url)
        self.click_element(Elements.FIRST_PRODUCT)
        return ProductDetailPage()